package cn.uexpo.lhz.biz.impl;

import java.util.List;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;



import cn.uexpo.lhz.biz.CameranotiyBiz;
import cn.uexpo.lhz.common.oldBase.BOException;
import cn.uexpo.lhz.common.oldUtils.PageRequest;
import cn.uexpo.lhz.common.oldUtils.PageResult;
import cn.uexpo.lhz.common.oldUtils.PageUtils;
import cn.uexpo.lhz.dao.CameranotiyMapper;
import cn.uexpo.lhz.domain.Cameranotiy;
import cn.uexpo.lhz.domain.CameranotiyExample;
import cn.uexpo.lhz.domain.Many3Vo;


@Transactional
@Service
public class CameranotiyBizImpl  implements CameranotiyBiz {


	@Autowired
	private CameranotiyMapper notiyMapper;
	@Override
	public int insert(Cameranotiy record) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.insert(record);
	}

	@Override
	public int insertSelective(Cameranotiy record) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.insertSelective(record);
	}

	@Override
	public int deleteByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.deleteByPrimaryKey(id);
	}

	@Override
	public int deleteEntity(Cameranotiy record) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.deleteByPrimaryKey(record.getId());
	}

	@Override
	public int deleteByIds(List<Integer> ids) throws BOException {
		// TODO Auto-generated method stub
		for (Integer id : ids) {
			notiyMapper.deleteByPrimaryKey(id);
		}
		return 1;
	}

	@Override
	public int delete(List<Cameranotiy> records) throws BOException {
		// TODO Auto-generated method stub
		for (Cameranotiy record : records) {
			notiyMapper.deleteByPrimaryKey(record.getId());
		}
		return 1;
	}

	@Override
	public int deleteByExample(CameranotiyExample example) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.deleteByExample(example);
	}

	@Override
	public int updateByPrimaryKey(Cameranotiy record) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.updateByPrimaryKey(record);
	}

	@Override
	public int updateByPrimaryKeySelective(Cameranotiy record) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.updateByPrimaryKeySelective(record);
	}

	@Override
	public int updateByExampleSelective(Cameranotiy record, CameranotiyExample example) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.updateByExampleSelective(record,example);
	}

	@Override
	public int updateByExample(Cameranotiy record, CameranotiyExample example) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.updateByExample(record,example);
	}

	@Override
	public Cameranotiy selectByPrimaryKey(Integer id) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.selectByPrimaryKey(id);
	}

	@Override
	public Cameranotiy selectByUniqueCode(String uniqueCode) throws BOException {
		// TODO Auto-generated method stub
		Cameranotiy item=null;
		CameranotiyExample example=new CameranotiyExample();
		CameranotiyExample.Criteria citeria=example.createCriteria();
		 citeria.andExtstr3EqualTo(uniqueCode);
		 List<Cameranotiy> items=notiyMapper.selectByExample(example);
		 if (items!=null&&items.size()>0) {
			 item=items.get(0);
		}
		return item;
	}

	@Override
	public List<Cameranotiy> selectByExample(CameranotiyExample example) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.selectByExample(example);
	}

	@Override
	public long countByExample(CameranotiyExample example) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.countByExample(example);
	}

	@Override
	public PageResult findPage(PageRequest pageRequest, CameranotiyExample example) throws BOException {
		int pageNum = pageRequest.getPage();
		int pageSize = pageRequest.getLimit();
	    PageHelper.startPage(pageNum, pageSize);
//	    List<Cameranotiy> records = (List<Cameranotiy>) notiyMapper.selectByExampleWithBLOBs(example);//初始化查看图片
	    List<Cameranotiy> records = (List<Cameranotiy>) notiyMapper.selectByExample(example);//初始化不查看图片
	    return PageUtils.getPageResult(pageRequest, new PageInfo<Cameranotiy>(records));
	}

	@Override
	public List<Cameranotiy> selectByExampleWithBLOBs(CameranotiyExample example) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.selectByExampleWithBLOBs(example);
	}

	@Override
	public int updateByExampleWithBLOBs(Cameranotiy record, CameranotiyExample example) throws BOException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public int updateByPrimaryKeyWithBLOBs(Cameranotiy record) throws BOException {
		// TODO Auto-generated method stub
		return notiyMapper.updateByPrimaryKeyWithBLOBs(record);
	}

	//添加maxIdByName方法
	@Override
	public int maxIdByName(String eqpname) {
		return notiyMapper.maxIdByName(eqpname);
	}

	@Override
	public List<Many3Vo> selectByAll(CameranotiyExample example) {
		// TODO Auto-generated method stub
		return notiyMapper.selectByAll(example);
	}

	@Override
	public List<Integer> selectMaxByAll(CameranotiyExample example) {
		return notiyMapper.selectMaxByAll(example);
	}

	@Override
	public Cameranotiy selectByNumber(Integer id) {
		return notiyMapper.selectByNumber(id);
	}

}
